//% color="#4169E1" iconWidth=50 iconHeight=40
namespace DFRobot_HX711_I2C{

    //% block="DFRobot_HX711_I2C Init [ADDR]     " blockType="command" 
    //% ADDR.shadow="dropdown" ADDR.options="ADDR"
     
    export function DFRobot_HX711_I2CInit(parameter: any, block: any) {
         let addr = parameter.ADDR.code;
          

        Generator.addInclude("DFRobot_HX711_I2CInit", "#include <DFRobot_HX711_I2C.h>");
        
        Generator.addObject("DFRobot_HX711_I2CInit","DFRobot_HX711_I2C",`MyScale(&Wire, ${addr});`);
  
        Generator.addSetup(`DFRobot_HX711_I2CInit`, `while (!MyScale.begin());`);
       
        
    }
    //% block="DFRobot_HX711_I2C  setCalWeight [NUMBER]" blockType="command"
    //% NUMBER.shadow="number" NUMBER.defl="100"
    export function DFRobot_HX711_I2CSetCalWeight(parameter: any, block: any) { 
        let number=parameter.NUMBER.code;

        Generator.addSetup(`DFRobot_HX711_I2CInit1`,`MyScale.setCalWeight(${number});`);
     
   
   }
      //% block="DFRobot_HX711_I2CSetThreshold [NUMBER1]" blockType="command"
    //% NUMBER1.shadow="number" NUMBER1.defl="30"
    export function DFRobot_HX711_I2CSetThreshold(parameter: any, block: any) { 
      let number1=parameter.NUMBER1.code;

      Generator.addSetup(`DFRobot_HX711_I2CInit6`,`MyScale.setThreshold(${number1});`);
   
 
 }
    //% block="DFRobot_HX711_I2C  enableCal  " blockType="command"
     
    export function DFRobot_HX711_I2CEnableCal(parameter: any, block: any) { 
        

        Generator.addSetup(`DFRobot_HX711_I2CInit3`,`MyScale.enableCal();`);
   
   }
        //% block="DFRobot_HX711_I2CGetCalFlag" blockType="boolean" 
  export function DFRobot_HX711_I2CGetCalFlag(parameter: any, block: any) { 
    Generator.addCode( `MyScale.getCalFlag()`);

}
   /*  //% block="DFRobot_HX711_I2C  peel  " blockType="command"
     
     export function DFRobot_HX711_I2CPeel(parameter: any, block: any) { 
        

        Generator.addSetup(`DFRobot_HX711_I2CInit5`,`MyScale.peel();`);
   
   }*/
     //% block="DFRobot_HX711_I2CSetCalibration  " blockType="command" 
     
  export function DFRobot_HX711_I2CSetCalibration(parameter: any, block: any) { 
      
        
    Generator.addSetup(`DFRobot_HX711_I2CInit8`,`MyScale.setCalibration(MyScale.getCalibration());`);

}

   //% block="DFRobot_HX711_I2C  readWeight " blockType="reporter" 
    
   export function DFRobot_HX711_I2CReadWeight(parameter: any, block: any) { 
      
        
    Generator.addCode( [`MyScale.readWeight()`,Generator.ORDER_UNARY_POSTFIX]);

}

  //% block="---"
  export function noteSep() {

  }
       //% block="DFRobot_HX711_I2CgetCalibration  " blockType="reporter" 
 
       export function DFRobot_HX711_I2CGetCalibration(parameter: any, block: any) { 
      
        
        Generator.addCode(`MyScale.getCalibration()`);
   
   }
    //% block="DFRobot_HX711_I2CSetCalibration [NUMBER2]" blockType="command" 
    //% NUMBER2.shadow="number" NUMBER2.defl="2000"
     
    export function DFRobot_HX711_I2CSetCalibration1(parameter: any, block: any) { 
      let number2=parameter.NUMBER2.code;
        
        Generator.addSetup(`DFRobot_HX711_I2CInit8`,`MyScale.setCalibration(${number2});`);
   
   }


}